class CreateRatingMarks < ActiveRecord::Migration
  def change
    create_table :rating_marks, :id => false do |t|
      t.string :state, :null => false

      t.references :user
      t.references :target, :polymorphic => true

      t.timestamps
    end
    execute <<-SQL
      ALTER TABLE rating_marks
        ADD CONSTRAINT index_user_target_unique
        PRIMARY KEY (user_id, target_type, target_id);
    SQL
  end
end
